const mongoose = require('mongoose')
const Role = require('./Role')
const schema = new mongoose.Schema({
    username: { type: String },
    password: {
        type: String,
        select: false,
        set(val) {
            return require('bcrypt').hashSync(val, 10);
        }
    },
    role: { type: mongoose.SchemaTypes.ObjectId, ref: 'Role' },
    email: { type: String },
    mobile: { type: String }
})

module.exports = mongoose.model('User', schema);